package softarch.portal.db.flatfile;

import java.util.Date;
import java.util.List;

import softarch.portal.data.RawData;
import softarch.portal.data.RegularData;
import softarch.portal.data.UserProfile;
import softarch.portal.db.DatabaseException;
import softarch.portal.db.DatabaseFacade;

public class CSVDBManager implements DatabaseFacade {
	private CSVDatabase database;

	public CSVDBManager(String dbUser, String dbPassword, String dbUrl) {
		database = new CSVDatabase(dbUser, dbPassword, dbUrl);
	}

	public void insert(UserProfile profile) throws DatabaseException {
		database.insertUserProfile(profile);
	}

	public void update(UserProfile profile) throws DatabaseException {
		database.updateUserProfile(profile);
	}

	public UserProfile findUser(String username) throws DatabaseException {
		return database.findUser(username);
	}

	public boolean userExists(String username) throws DatabaseException {
		return database.userExists(username);
	}

	public List findRecords(String informationType, String queryString)
			throws DatabaseException {
		return database.findRecords(informationType, queryString);
	}

	public List findRecordsFrom(String informationType, Date date)
			throws DatabaseException {
		return database.findRecordsFrom(informationType, date);
	}

	public void add(RegularData rd) throws DatabaseException {
		database.addRegularData(rd);
	}

	public int getNumberOfRegularRecords(String informationType)
			throws DatabaseException {
		return database.getNumberOfRegularRecords(informationType);
	}

	public List getRawData() throws DatabaseException {
		return database.getRawData();
	}

	public RawData getRawData(int id) throws DatabaseException {
		return database.getRawData(id);
	}

	public void addRawData(RegularData rd) throws DatabaseException {
		database.addRawData(rd);
	}

	public void deleteRawData(RawData rd) throws DatabaseException {
		database.deleteRawData(rd);
	}

	public void updateRawData(RawData rd) throws DatabaseException {
		database.updateRawData(rd);
	}

	public int getNumberOfRawRecords() throws DatabaseException {
		return database.getNumberOfRawRecords();
	}

}
